/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "多线程.h"

#include <thread>
#include <ppl.h>
#include <future>
//#pragma comment(lib,"pthreadVC2.lib")



C_线程池::C_线程池(uint32 range, uint32 线程数, f_线程运行函数指针 cpthread) {
	m_数量 = range;
	m_线程数 = DEF_Min(range, 线程数);
	m_区间跨度 = (range / m_线程数) + 1;
	m_区间 = { 0, m_区间跨度 };

	m_线程数 = (range / m_区间跨度) + 1;

	if (cpthread) {
		for (uint32 i = 0; i < m_线程数; ++i) {
			
		}
		
	}
	else {
		//m_线程.resize(m_线程数);
	}
	//m_线程c.resize(m_线程数);
	m_线程参数.resize(m_线程数);
}

C_线程池::~C_线程池()
{
}

void C_线程池::f_运行(f_线程运行函数指针 fun, void* 线程参数) {
	/*uvec2 range = m_区间;
	for (uint32 i = 0; i < m_线程数; ++i) {
		if (range.y > m_数量) range.y = m_数量;

		m_线程参数[i] = { range, 线程参数 };
		pthread_create(&m_线程c[i], NULL, fun, &m_线程参数[i]);

		if (range.y >= m_数量) break;

		range.x += m_区间跨度;
		range.y += m_区间跨度;
	}*/
}

void C_线程池::f_等待c()
{
	/*for (auto& t : m_线程c) {
		void* data;
		void pthread_join(t, &data);
	}*/
}








